package com.dyz.model;

import java.util.ArrayList;
import java.util.List;

public class ReportServiceImpl implements ReportService {

	Report rt = Report.getInstance();
	List<Invoice> reportList = new ArrayList<>();
	private String report = "";

	@Override
	public void createReport(int month) {
	//	P.p("createReport()");
		makeReportList(month);

		for (Invoice inv : reportList) {

			report = report.concat(inv.toString()+System.lineSeparator());
			
		}

	}

	@Override
	public String getReport() {
		return report;
	}

	private void makeReportList(int month) {

		for (Invoice inv : rt.getInvoice()) {
			if (inv.getMonth() == month)
				reportList.add(inv);
		//	P.p("makereportlist()");

		}

	}

}
